﻿Public Class SampleWebconfigFile
    Public Function GetConfigFile(ByVal ConnectionStringMethod As String, ByVal ConnectionStringName As String, ByVal dtp As DataTabPage, ByVal DatabaseName As String) As String
        Dim s As String = ""
        Dim Spaces As New Space

        s = s & "<?xml version=""1.0""?>" & vbCrLf
        s = s & Spaces.ToString() & "<configuration>" & vbCrLf
        Spaces.Inc()
        s = s & Spaces.ToString() & "<appSettings/>" & vbCrLf
        s = s & Spaces.ToString() & "<system.web>" & vbCrLf
        Spaces.Inc()
        s = s & Spaces.ToString() & "<compilation debug=""true"" strict=""false"" explicit=""true""/>" & vbCrLf
        s = s & Spaces.ToString() & "<pages>" & vbCrLf
        Spaces.Inc()
        s = s & Spaces.ToString() & "<namespaces>" & vbCrLf
        Spaces.Inc()
        s = s & Spaces.ToString() & "<clear/>" & vbCrLf

        s = s & Spaces.ToString() & "<add namespace=""System""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Collections""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Collections.Specialized""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Configuration""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Text""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Text.RegularExpressions""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.Caching""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.SessionState""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.Security""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.Profile""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.UI""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.UI.WebControls""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.UI.WebControls.WebParts""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Web.UI.HtmlControls""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Data.SqlClient""/>" & vbCrLf
        s = s & Spaces.ToString() & "<add namespace=""System.Data""/>" & vbCrLf
        Spaces.Dec()
        s = s & Spaces.ToString() & "</namespaces>" & vbCrLf
        Spaces.Dec()
        s = s & Spaces.ToString() & "</pages>" & vbCrLf
        s = s & Spaces.ToString() & "<authentication mode=""None""/>" & vbCrLf
        s = s & Spaces.ToString() & "<customErrors mode=""Off""></customErrors>" & vbCrLf
        Spaces.Dec()
        s = s & Spaces.ToString() & "</system.web>" & vbCrLf
        s = s & Spaces.ToString() & "<connectionStrings>" & vbCrLf
        Spaces.Inc()

        'Public Name As String = ""
        'Public UserName As String = ""
        'Public Password As String = ""
        'Public AuthenticationType As String = ""
        'Public RememberPassword As String = ""
        If ConnectionStringMethod.ToUpper.Trim = "WEB.CONFIG CONNECTION STRINGS" Then
            Dim ConnectionString As String = ""
            If dtp.DatabaseServer.AuthenticationType = DatabaseAuthenticationType.WindowsAuthentication Then
                ConnectionString = "Database=" & DatabaseName & ";Server=" & dtp.ServerName & ";Integrated Security=SSPI;"
            Else
                ConnectionString = "Database=" & DatabaseName & ";Server=" & dtp.ServerName & ";uid=" & dtp.DatabaseServer.Login & ";PWD=" & dtp.DatabaseServer.Password & ";Connect Timeout=30;Network Library =dbmssocn"
            End If
            s = s & Spaces.ToString() & "<add name=""" & ConnectionStringName & """ connectionString=""" & ConnectionString & """/>" & vbCrLf
        End If
        'If ConnectionStringMethod <> "MapPath" Then
        '    s = s & Spaces.ToString() & "<add name=""" & ConnectionStringName & """ connectionString=""""/>" & vbCrLf
        'End If
        Spaces.Dec()
        s = s & Spaces.ToString() & "</connectionStrings>" & vbCrLf
        Spaces.Dec()
        s = s & Spaces.ToString() & "</configuration>" & vbCrLf
        Return s

    End Function
End Class
